<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['pluginset']=$this->plugin_setting('setting');
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$isfee=intval($_RQ['isfee']);
	$return['setting']=$this->plugin_setting('page_setting');
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','mobile','avatar','nickname'));
	$newmember=pdo_get('jy_yangjidan_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['member']=array_merge($member,$newmember);
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($isfee){
		$params['type']=array(2,4,7,8);
	}else{
		$params['type']=array(1,3,5,6);
	}
	$return['commission_money']=$this->sum('commission',$params,'money');
	$return['commission_total']=$this->count('commission',$params);
	$params['status']=0;
	$return['commission_money']=$this->sum('commission',$params,'money');
	$return['cvlog']['allcv']=$return['member']['allcv'];
	$return['cvlog']['cv3']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>3,'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['cvlog']['cancv']=$return['member']['cv']+$return['cvlog']['cv3'];
	$return['cvlog']['iscv']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'isadd'=>0,'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['cvlog']['cv4']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>4,'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['cvlog']['cv0']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>0,'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['cvlog']['cv1']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>1,'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['list']=array();
	$return['params']=array(
		'isfee'=>$isfee,
		'page'=>1,
	);
	$return['psize']=20;
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($_RQ['isfee']){
		$params['type']=array(2,4,7,8);
	}else{
		$params['type']=array(1,3,5,6);
	}
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=$this->get_list('commission',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$order=$this->get('order',array('uniacid'=>$_SESSION['uniacid'],'ordersn'=>$item['ordersn']));
		$item['member']=model('core/member')->basic($order['mid']);
		$item['typetitle']=$this->commission_money_types[$item['type']];
	}
	exi($list);
}
?>